package com.qby.e_commerce.controller;

import com.qby.e_commerce.entity.WalletDetails;
import com.qby.e_commerce.service.WalletDetailsService;
import com.qby.e_commerce.service.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@RequestMapping("walletDetails")
public class WalletDetailsController {

    @Autowired
    private WalletDetailsService walletDetailsService;

    /**
     * 新增交易记录
     * @param walletDetails
     * @return
     */
    @PostMapping("addTransaction")
    public Integer addTransaction(@RequestBody WalletDetails walletDetails) throws Exception {
        return walletDetailsService.addTransaction(walletDetails);
    }

    /**
     * 查询用户钱包金额变动明细的接口，按时间降序排列
     * @param walletId
     * @return
     */
    @GetMapping("/queryWalletDetails")
    public List<WalletDetails> queryWalletDetails(Integer walletId){
        return walletDetailsService.queryWalletDetails(walletId);
    }

}
